package fr.pascal.old;

import java.io.File;
import java.io.IOException;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

public class JsonObject {
	
	public static void main(String[] args) throws JsonGenerationException, JsonMappingException, IOException {
		
		ObjectMapper mapper = new ObjectMapper();
		
		// object => json
		User user = new User();
		mapper.writeValue(new File("user.json"), user);
		System.out.println(mapper.writeValueAsString(user));
		
		// json => object
		user = mapper.readValue(new File("user2.json"), User.class);
		System.out.println(user);
	}
}
